package ejb.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;

/**
 * The persistent class for the groups database table.
 * 
 */
@Entity
@Table(name = "groups")
@NamedQueries({
		@NamedQuery(name = "Group.findAll", query = "SELECT g FROM Group g"),
		@NamedQuery(name = "Group.findbyName", query = "SELECT g FROM Group g WHERE g.groupid LIKE :id")

})
public class Group implements Serializable {
	private static final long serialVersionUID = 1L;

	// attributi per le query
	public static final String FINDBYNAME = "Group.findbyName";
	public static final String FINDALL = "Group.findbyAll";

	// attributi per i RolesAllowed
	public static final String USER = "USERS";
	public static final String ADMIN = "ADMINS";

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	private String groupid;

	// bi-directional many-to-many association to User
	@ManyToMany
	@JoinTable(name = "user_group", joinColumns = { @JoinColumn(name = "groupid") }, inverseJoinColumns = { @JoinColumn(name = "userid") })
	private List<User> users;

	public Group() {
	}

	public String getGroupid() {
		return groupid;
	}

	public void setGroupid(String groupid) {
		this.groupid = groupid;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

}